package com.cmse.persistence.domain;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;


/**
 * @author wulibin, exceptsky@gmail.com, 2012-3-12 下午8:02:43
 * 
 */
@Entity
@Table(name="artical")
public class Artical implements Serializable {
	private static final long serialVersionUID = -7360736964343056500L;

	private Long id;	
	private String title;													//文章标题
	private String content;													//文章内容
	private String summary;													//摘要
	private Integer commentNum = new Integer(0);							//评论数
	private Integer categoryID;												//文章分类ID
	private String category;												//文章分类名称
	private Boolean allowComment = new Boolean(true);						//是否允许评论
	private Boolean allowAnonymousComment = new Boolean(false);				//是否允许匿名评论
	private User author;													//作者
	private Date createdAt;													//创建日期
	private Date modifiedAt;												//最后修改日期
	
	public Artical() {}

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@Column(name="title", length=100)
	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	@Lob
	@Column(name="content")
	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	@Lob
	@Column(name="summary")
	public String getSummary() {
		return summary;
	}

	public void setSummary(String summary) {
		this.summary = summary;
	}

	@Column(name="comment_num")
	public Integer getCommentNum() {
		return commentNum;
	}

	public void setCommentNum(Integer commentNum) {
		this.commentNum = commentNum;
	}
	
	@Column(name="category_id")
	public Integer getCategoryID() {
		return categoryID;
	}

	public void setCategoryID(Integer categoryID) {
		this.categoryID = categoryID;
	}
	

	@Column(name="category")
	public String getCategory() {
		return category;
	}

	public void setCategory(String category) {
		this.category = category;
	}
	

	@Column(name="allowComment")
	public Boolean getAllowComment() {
		return allowComment;
	}

	public void setAllowComment(Boolean allowComment) {
		this.allowComment = allowComment;
	}
	@Column(name="allowAnonymousComment")
	public Boolean getAllowAnonymousComment() {
		return allowAnonymousComment;
	}

	public void setAllowAnonymousComment(Boolean allowAnonymousComment) {
		this.allowAnonymousComment = allowAnonymousComment;
	}

	@ManyToOne
	@JoinColumn(name="author_id", nullable=false)
	public User getAuthor() {
		return author;
	}

	public void setAuthor(User author) {
		this.author = author;
	}

	@Column(name="createdAt")
	@Temporal(TemporalType.TIMESTAMP)
	public Date getCreatedAt() {
		return createdAt;
	}

	public void setCreatedAt(Date createdAt) {
		this.createdAt = createdAt;
	}

	@Column(name="modifiedAt")
	@Temporal(TemporalType.TIMESTAMP)
	public Date getModifiedAt() {
		return modifiedAt;
	}

	public void setModifiedAt(Date modifiedAt) {
		this.modifiedAt = modifiedAt;
	}
	
}